package com.lxmes.business.service.impl;

import java.util.List;
import com.lxmes.common.utils.DateUtils;
import com.lxmes.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.lxmes.business.mapper.CcStockInfoMapper;
import com.lxmes.business.domain.CcStockInfo;
import com.lxmes.business.service.ICcStockInfoService;

/**
 * 库存明细Service业务层处理
 *
 * @author 张志煜
 * @date 2022-11-29
 */
@Service
public class CcStockInfoServiceImpl implements ICcStockInfoService
{
    @Autowired
    private CcStockInfoMapper ccStockInfoMapper;

    /**
     * 查询库存明细
     *
     * @param id 库存明细主键
     * @return 库存明细
     */
    @Override
    public CcStockInfo selectCcStockInfoById(Long id)
    {
        return ccStockInfoMapper.selectCcStockInfoById(id);
    }

    /**
     * 查询库存明细列表
     *
     * @param ccStockInfo 库存明细
     * @return 库存明细
     */
    @Override
    public List<CcStockInfo> selectCcStockInfoList(CcStockInfo ccStockInfo)
    {
        ccStockInfo.setFactoryCode(SecurityUtils.getFactoryCode());
        return ccStockInfoMapper.selectCcStockInfoList(ccStockInfo);
    }

    @Override
    public List<CcStockInfo> selectCcStockInfoList1(CcStockInfo ccStockInfo) {
        ccStockInfo.setFactoryCode(SecurityUtils.getFactoryCode());
        return ccStockInfoMapper.selectCcStockInfoList1(ccStockInfo);
    }

    @Override
    public List<CcStockInfo> selectCcStockInfoSelectList(CcStockInfo ccStockInfo) {
        ccStockInfo.setFactoryCode(SecurityUtils.getFactoryCode());
        return ccStockInfoMapper.selectCcStockInfoList2(ccStockInfo);
    }

    @Override
    public CcStockInfo selectCcStockInfoBySmCk(CcStockInfo ccStockInfo) {
       ccStockInfo.setFactoryCode(SecurityUtils.getFactoryCode());
       CcStockInfo stockInfo= ccStockInfoMapper.selectCcStockInfoBySmCk(ccStockInfo);
       if(stockInfo==null){
           throw new RuntimeException("无数据！！！");
       }
        return stockInfo;
    }

    @Override
    public List<CcStockInfo>  selectCcStockInfoMainList(CcStockInfo ccStockInfo) {
        ccStockInfo.setFactoryCode(SecurityUtils.getFactoryCode());
        return ccStockInfoMapper.selectCcStockInfoMainList(ccStockInfo);
    }

    @Override
    public List<CcStockInfo> selectCcStockInfoListExport(CcStockInfo ccStockInfo) {
        ccStockInfo.setFactoryCode(SecurityUtils.getFactoryCode());
        return ccStockInfoMapper.selectCcStockInfoListExport(ccStockInfo);
    }

    /**
     * 新增库存明细
     *
     * @param ccStockInfo 库存明细
     * @return 结果
     */
    @Override
    public int insertCcStockInfo(CcStockInfo ccStockInfo)
    {
        ccStockInfo.setCreateTime(DateUtils.getNowDate());
        return ccStockInfoMapper.insertCcStockInfo(ccStockInfo);
    }

    /**
     * 修改库存明细
     *
     * @param ccStockInfo 库存明细
     * @return 结果
     */
    @Override
    public int updateCcStockInfo(CcStockInfo ccStockInfo)
    {
        ccStockInfo.setUpdateTime(DateUtils.getNowDate());
        return ccStockInfoMapper.updateCcStockInfo(ccStockInfo);
    }

    /**
     * 批量删除库存明细
     *
     * @param ids 需要删除的库存明细主键
     * @return 结果
     */
    @Override
    public int deleteCcStockInfoByIds(Long[] ids)
    {
        return ccStockInfoMapper.deleteCcStockInfoByIds(ids);
    }

    /**
     * 删除库存明细信息
     *
     * @param id 库存明细主键
     * @return 结果
     */
    @Override
    public int deleteCcStockInfoById(Long id)
    {
        return ccStockInfoMapper.deleteCcStockInfoById(id);
    }
}
